//
//  LRJVideoDetailTableViewCell.m
//  BreadTravel
//
//  Created by 李润嘉 on 15/12/30.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "LRJVideoDetailTableViewCell.h"

@implementation LRJVideoDetailTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return self;
}
- (void)createSubView
{
    self.nameLabel = [[UILabel alloc] init];
    self.nameLabel.font = [UIFont systemFontOfSize:18];
    [self.contentView addSubview:self.nameLabel];
    
    self.tagsLabel = [[UILabel alloc] init];
    self.tagsLabel.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.tagsLabel];
    
    self.videoDurationLabel = [[UILabel alloc] init];
    self.videoDurationLabel.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.videoDurationLabel];
    
    self.introLabel = [[UILabel alloc] init];
    self.introLabel.numberOfLines = 0;
    [self.contentView addSubview:self.introLabel];
    
}

- (void)setVideoModel:(LRJVideoDetailModel *)videoModel
{
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(@20);
        make.left.mas_equalTo(@10);
        make.width.mas_equalTo(WIDTH - 20);
        
        
    }];
    
    [self.tagsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.nameLabel.mas_bottom).offset(10);
        make.left.equalTo(self.nameLabel.mas_left);
        make.width.mas_equalTo(@40);
        
    }];
    
    [self.videoDurationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self.tagsLabel.mas_right);
        make.top.equalTo(self.nameLabel.mas_bottom).offset(10);
        make.width.mas_equalTo(@50);
        
    }];
    
    [self.introLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.tagsLabel.mas_bottom).offset(10);
        make.width.mas_equalTo(WIDTH - 20);
        make.left.mas_equalTo(@10);
        
    }];
    
    self.nameLabel.text = videoModel.name;
    self.tagsLabel.text = videoModel.tags;
    NSInteger videoM = videoModel.videoDuration / 60;
    NSInteger videoS = videoModel.videoDuration % 60;
    self.videoDurationLabel.text = [NSString stringWithFormat:@"/ %ld ' %ld''", videoM, videoS];
    self.introLabel.text = videoModel.intro;
    
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
